﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace TestManage
{
    public class Program
    {
        public static void Main(string[] args)
        {
            CreateWebHostBuilder(args)
                .Build()
                .Run();
        }

        //public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        //    WebHost.CreateDefaultBuilder(args)
        //     //.ConfigureAppConfiguration((hostingContext, builder) =>
        //     //{
        //     //    builder
        //     //    .SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
        //     //    .AddJsonFile("ocelot.json", false, true);
        //     //})
        //    .UseKestrel()
        //    .UseUrls("http://*:13846")
        //    .UseStartup<Startup>();



        //public static IWebHostBuilder CreateWebHostBuilder(string[] args)
        //{
        //    //解析出从控制台传入的ip和端口号
        //    var config = new ConfigurationBuilder()
        //        .AddCommandLine(args)
        //        .Build();
        //    string ip = config["ip"];
        //    string port = config["port"];

        //    return WebHost.CreateDefaultBuilder(args)
        //        .UseKestrel()
        //        .UseUrls($"http://{ip}:{port}")
        //        //注册应用配置
        //        .ConfigureAppConfiguration((hostingContext, builder) => {
        //            //false 此文件是否是可选的，不是！true 如果此文件被修改了是否重新加载 是！
        //            builder.AddJsonFile("ocelot.json", false, true);
        //        })
        //        .UseStartup<Startup>();
        //}

        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
           WebHost.CreateDefaultBuilder(args)
               .UseKestrel(options => options.AddServerHeader = false)
               .UseStartup<Startup>();
    }
}
